package com.xiaoyu.lanling.feature.register.data

import com.xiaoyu.base.model.User
import com.xiaoyu.base.net.RequestCreator
import com.xiaoyu.lanling.common.config.HttpConfig
import com.xiaoyu.lanling.event.register.CheckInviteCodeEvent
import com.xiaoyu.lanling.event.register.RandomAvatarEvent
import com.xiaoyu.lanling.event.register.RandomNameEvent

class RegisterData {

    companion object {
        fun randomName(requestTag: Any, sex: String = User.SEX_MAN) {
            RequestCreator.create<RandomNameEvent>(requestTag, RandomNameEvent::class.java)
                    .setRequestUrl(HttpConfig.LANLING_RANDOM_NAME)
                    .addQueryData("sex", sex)
                    .enqueue()
        }

        fun randomAvatar(requestTag: Any, sex: String) {
            RequestCreator.create<RandomAvatarEvent>(requestTag, RandomAvatarEvent::class.java)
                    .setRequestUrl(HttpConfig.LANLING_RANDOM_AVATAR)
                    .addQueryData("sex", sex)
                    .enqueue()
        }

        fun checkInviteCode(requestTag: Any, inviteCode: String) {
            RequestCreator.create<CheckInviteCodeEvent>(requestTag, CheckInviteCodeEvent::class.java)
                    .setRequestUrl(HttpConfig.LANLING_CHECK_INVITE_CODE)
                    .setPostEventWhenFail(true)
                    .addQueryData("inviteCode", inviteCode)
                    .enqueue()
        }
    }
}